using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace NhaThuocOnline.Entities.Mapping
{
    public class BietDuocMap : EntityTypeConfiguration<BietDuoc>
    {
        public BietDuocMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.ID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.TenThuoc)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("BietDuoc");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.TenThuoc).HasColumnName("TenThuoc");
            this.Property(t => t.HoatChat).HasColumnName("HoatChat");
            this.Property(t => t.DieuKienBaoQuan).HasColumnName("DieuKienBaoQuan");
            this.Property(t => t.NhomDieuTriId).HasColumnName("NhomDieuTriId");
            this.Property(t => t.DonViTinhId).HasColumnName("DonViTinhId");
            this.Property(t => t.QuyCachDongGoiId).HasColumnName("QuyCachDongGoiId");
            this.Property(t => t.NuocSanXuatId).HasColumnName("NuocSanXuatId");
            this.Property(t => t.NhaSanXuatId).HasColumnName("NhaSanXuatId");
            this.Property(t => t.LoaiSanPhamId).HasColumnName("LoaiSanPhamId");
            this.Property(t => t.NgayCapNhat).HasColumnName("NgayCapNhat");
            this.Property(t => t.PhanLoaiThuocId).HasColumnName("PhanLoaiThuocId");

            // Relationships
            this.HasOptional(t => t.LoaiSanPham)
                .WithMany(t => t.BietDuocs)
                .HasForeignKey(d => d.LoaiSanPhamId);
            this.HasOptional(t => t.NhaSanXuat)
                .WithMany(t => t.BietDuocs)
                .HasForeignKey(d => d.NhaSanXuatId);
            this.HasOptional(t => t.PhanLoaiThuoc)
                .WithMany(t => t.BietDuocs)
                .HasForeignKey(d => d.PhanLoaiThuocId);
            this.HasOptional(t => t.QuyCachDongGoi)
                .WithMany(t => t.BietDuocs)
                .HasForeignKey(d => d.QuyCachDongGoiId);
            this.HasOptional(t => t.NuocSanXuat)
                .WithMany(t => t.BietDuocs)
                .HasForeignKey(d => d.NuocSanXuatId);
            this.HasOptional(t => t.NhomDieuTri)
                .WithMany(t => t.BietDuocs)
                .HasForeignKey(d => d.NhomDieuTriId);
            this.HasOptional(t => t.DonViTinh)
                .WithMany(t => t.BietDuocs)
                .HasForeignKey(d => d.DonViTinhId);

        }
    }
}
